import '@/common/uni.css'
import '@/common/anstyle.css'
import '@/static/font/iconfont.css'
import '@/common/base.css'
import Vue from 'vue'
import App from './App'

import store from './store'
import api from '@/common/vmeitime-http/'
import _GENV from '@/common/env.js'

Vue.config.productionTip = false
Vue.prototype.$_GENV = _GENV
Vue.prototype.$store = store
Vue.prototype.$api = api
Vue.prototype.backrefresh =function (data) {  
   let pages = getCurrentPages(); // 当前页面
   let beforePage = pages[pages.length - 2]; // 前一个页面
    console.log("beforePage");
   console.log(beforePage);
   uni.navigateBack({
       success: function() {
		   if(beforePage.backRefresh){
				 beforePage.backRefresh(data); // 执行前一个页面的onLoad方法
		   }
          
       }
   });
}; 
   
Vue.prototype.isloading =function (data) {  
	
		// var httpshowpath=sessionStorage.getItem("httpshowpath");	
		var httpshowpath=sessionStorage.getItem("isloadingget");
		if(httpshowpath){			
			return true;	
		}else{
			return false;
		}
};
Vue.prototype.islogin =function (data) {  
    var tokensen=sessionStorage.getItem("tokensession"); 
	if(tokensen){
		return true;
	}else{
		return false;
	}
}; 

Vue.prototype.showm_status =function(data){
	if(data==0){
		return '待访问';
	}else if(data==1){
		return '已访问';
	}else if(data==2){
		return '已逾期';
	}else if(data==3){
		return '已逾期';
	}else if(data==4){
		return '已暂停';
	}else if(data==5){
		return '不接受';
	}else if(data==6){
		return '已接受';
	}else if(data==7){
		return '已审核';
	}else if(data==8){
		return '待审核';
	}else if(data==9){
		return '审核不过';
	}else if(data==10){
		return '待审核';
	}else if(data==11){
		return '待确认';
	}else if(data==12){
		return '已取消';
	}else if(data==13){
		return '待答题';
	}
}
Vue.prototype.isgologin =function (data) {  
    var tokensen=sessionStorage.getItem("tokensession"); 
	
	if(tokensen){
		return true;
	}else{
		//开发环境调试
		// return true;
		//
		uni.showModal({
		    title: '',
		    content: '抱歉,您还没有登录，不能操作此按钮',						
			// showCancel:false,
			confirmText: "去登录",
		    success: function (res) {
		        if (res.confirm) {
					var local ='https://' + _GENV.Gdomain + '/wap/#/pages/shouquan/shouquan'; // 获取页面url
						var appid = _GENV.GwechatAppid;
						var href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(
					local
					)}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`;				
						window.location.replace(href);
		        } else if (res.cancel) {
		            console.log('用户点击取消');
		        }
		    }
		});
	}
};

Vue.prototype.goshouji =function (data) { 
	var routing=sessionStorage.getItem("routing");
	
	if(routing=='ismoblie'){
		uni.reLaunch({
			url: '/pages/shouquan/shouji?restype='+data
		});
	}else if(routing=='isIdentitycard'){
		if(data=='1'){
			uni.reLaunch({
				url: '/pages/shouquan/shenfen'
			});
		}else{
			uni.reLaunch({
				url: '/pages/shouquan/shengfen'
			});
		}
	
	}else{
		uni.reLaunch({
			url: '/pages/shouquan/shouji?restype='+data
		});
	}
	
}
Vue.prototype.gologin =function (data) {  
    var tokensen=sessionStorage.getItem("tokensession"); 
	
	if(tokensen){
		return true;
	}else{
		//开发环境调试
		// return true;
		//

			var local ='https://' + _GENV.Gdomain + '/wap/#/pages/shouquan/shouquan'; // 获取页面url
				var appid = _GENV.GwechatAppid;
				var href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(
			local
			)}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`;				
				window.location.replace(href);
			
	}
};

Vue.prototype.showlogin =function (data) {  
    var tokensen=sessionStorage.getItem("tokensession"); 
	
	if(tokensen){
		return true;
	}else{
		return false;
		
	}
};
Vue.prototype.weixinhttpurl = _GENV.Gdoamin_https+'/wap'; //分享连接
Vue.prototype.sharehttpurl = _GENV.Gdoamin_https;//图片地址连接
Vue.prototype.apihttpurl = _GENV.GApi;//请求连接

// 调试工具
//import VConsole from '@/common/vconsole.min.js' // import vconsole
//全局引入 （main.js 加载上下滑动
// import wsLoadMore from './components/wsure-load-more/load-more.vue';
// Vue.component('wsLoadMore',wsLoadMore)

// 在main.js注册全局组件
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)

App.mpType = 'app'
import inputSearch from './components/inputSearch.vue'
Vue.component('inputSearch', inputSearch)


import loading from './components/loading.vue'
Vue.component('loading', loading)


Vue.filter('personimg', function (value) {
 
 if(value.toString().indexOf("zsicp.com") <= -1)     /*如果当前网址中没有abc.com*/ 
 { 
 var value = 'https://' + _GENV.Gdomain + '/public/upload/person/'+value;
  return value;
 } 
 else
 {
	// var value = 'https:///public/upload/person/'+value;
	return value; 
 }
 
 
})


Vue.filter('isidcard', function (data) {
 
	if(data){
		 var strcard=data.replace(/^(.{4})(?:\d+)(.{4})$/,"$1******$2"); 
		return strcard;
	}else{
		var strcard='-';
		return strcard;
	}
 
 
})


import no_data from './components/no_data.vue'
Vue.component('nodata', no_data)
import backnext from './components/backall.vue'
Vue.component('backnext', backnext)

import footernav from './components/footer.vue'
Vue.component('footernav', footernav)

import footerTips from 'components/footerTips.vue'
Vue.component('footerTips', footerTips)

//注册uView
import uView from 'uview-ui';
Vue.use(uView);

const app = new Vue({
    store,
    ...App
})
app.$mount()
